using Core.Contracts.Interfaces;

namespace Core.Features
{
    using System;
    using Base;
    using Contracts.Enums;
    using Resources;

    
    public sealed class SignalMasking<T> : FeatureBase<object>
    {
        public SignalMasking(){}

        public SignalMasking(T value) 
            : base(value){ }
        /// <summary>
        /// Obtains the feature name
        /// </summary>
        public override string Name
        {
            get { return "Signal masking"; }
        }
        /// <summary>
        /// Obtains the feature group
        /// </summary>
        public override FeatureGroupsEnum FeatureGroup{ get { return FeatureGroupsEnum.TargetingEquipment; } }
        /// <summary>
        /// Obtains the feature type
        /// </summary>
        public override FeaturesEnum FeatureType { get { return FeaturesEnum.SignalMasking; } }
        /// <summary>
        /// Obtains or defines the feature unit
        /// </summary>
        public override string Unit { get { return Traduction.label_unit_rf; } }


        public override void SetModifiedValue(IAgent agent, IRobot robot)
        {
            if (agent == null || robot == null) return;

            var moduleBonus = robot.Modules.SumModifiersValues(FeatureTypesEnum.Robot, this.FeatureType, ModuleGroupsEnum.SignalMaskers);

            double temp = (double)Value * (1 + moduleBonus);

            ModifiedValue = IsRounded
                                ? Math.Round(temp, 0, MidpointRounding.AwayFromZero)
                                : Math.Round(temp, 2);
        }
    }
}